package com.example.springbootdatamock.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@DS("mysql")
@Mapper
public interface MysqlMapper {
  @Update({"CREATE TABLE IF NOT EXISTS `di` (  `dt` DATETIME NOT NULL,  `orderCount` BIGINT DEFAULT NULL,  `refundCount` BIGINT DEFAULT NULL,  PRIMARY KEY (`dt`)) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"})
  void createTable();
  
  @Insert({" INSERT INTO di VALUES(#{date},#{oc},#{rc}) ON DUPLICATE KEY UPDATE ordercount=ordercount + VALUES(ordercount), refundCount=refundCount + VALUES(refundCount)"})
  void insertData(@Param("date") String paramString, @Param("oc") Integer paramInteger1, @Param("rc") Integer paramInteger2);
}


